import json

from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from pymysql.converters import escape_string


#  SELECT DISTINCT movie_name FROM tb_movie_script;     去重

from SQL_CRUD_Interface.CRUD import select_interface


@csrf_exempt
def movies(request):
    sql = '   SELECT DISTINCT movie_name FROM tb_movie_script;    '
    result = select_interface("127.0.0.1", "root", "root", "study_english_database", sql)
    movie_name_list = []
    for ii in result:
        movie_name_list.append(ii[0])
    json_data = json.dumps(movie_name_list)
    return HttpResponse(json_data)
